<script lang="ts" setup>
import type { PerPostExperienceApi } from '#/api/per/postExperience';

import { ref } from 'vue';

import { useVbenModal } from '@vben/common-ui';

import { getPostExperience } from '#/api/per/postExperience';
import PostExperienceDetail from '#/views/per/components/postExperience/postExperienceDetail.vue';

const formData = ref<PerPostExperienceApi.PostExperience>();

const [Modal, modalApi] = useVbenModal({
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      formData.value = undefined;
      return;
    }
    let data = modalApi.getData<PerPostExperienceApi.PostExperience>();
    if (!data || !data.id) {
      return;
    }
    modalApi.lock();
    try {
      data = await getPostExperience(data.id);
      formData.value = data;
    } finally {
      modalApi.unlock();
    }
  },
});
</script>

<template>
  <Modal
    title="查看 岗位情况"
    class="w-[60%]"
    :show-cancel-button="false"
    :show-confirm-button="false"
  >
    <PostExperienceDetail :data="formData" class="mx-4" />
  </Modal>
</template>
